package service

import (
	"go-ws-server/config"
	"go-ws-server/model/dto"
)

// 方法1： 查询在线用户信息
func GetOnlineUsers() ([]dto.UserInfo, error) {
	var users []dto.UserInfo

	err := config.GetDB().
		Where("used = ?", "1").
		Order("CASE WHEN status = 'online' THEN 1 ELSE 0 END DESC").
		Order("last_online_time DESC").
		Find(&users).Error

	return users, err
}
